package cc.rengu.redp.hawk.job;

import cc.rengu.redp.common.utils.HttpUtil;
import cc.rengu.redp.common.utils.SpringContextUtil;
import cc.rengu.redp.hawk.service.HawkMonitorService;

import java.io.IOException;

public class HawkPullJob {

    private String url;

    private String hawkId;

    private HawkMonitorService hawkMonitorService = SpringContextUtil.getBean(HawkMonitorService.class);

    public HawkPullJob(String hawkId, String url) {
        this.hawkId = hawkId;
        this.url = url;
    }

    void run() throws IOException {
        String jsonStr = HttpUtil.get(url, null);
        hawkMonitorService.push(hawkId, jsonStr);
    }
}
